package cn.ren.cloud.fallback;

import cn.ren.cloud.enums.GlobelExceptionEnum;
import cn.ren.cloud.feign.CourseFeignClient;
import cn.ren.cloud.feign.CourseUserLearnFeignClient;
import cn.ren.cloud.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author 23508
 */
@Component
public class CourseUserLearnFeignClientFallbackFactory implements FallbackFactory<CourseUserLearnFeignClient> {
    @Override
    public CourseUserLearnFeignClient create(Throwable throwable) {
        return new CourseUserLearnFeignClient() {

            /**
             * feign接口调用
             *
             * @param courseId
             * @param loginId
             * @return
             */
            @Override
            public JsonResult getByCourseId(Long courseId, Long loginId) {
                return JsonResult.error(GlobelExceptionEnum.COMMON_REPEAT_OPERATION_ERROR.getMessage(), GlobelExceptionEnum.COMMON_REPEAT_OPERATION_ERROR.getCode());
            }
        };
    }
}
